package com.net.tool;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;

public class DownloadReceiver extends BroadcastReceiver {

	public void onReceive(Context context, Intent intent) {

		if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {

			@SuppressWarnings("deprecation")
			NetworkInfo info = (NetworkInfo) intent
					.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);

			if (info != null && info.isConnected()
					&& info.getType() == ConnectivityManager.TYPE_WIFI) {

				Log.d("DownloadReceiver", "wifi 已经连接 检测失败的内容");

				BasicDownload.fixNetworkERROR(context);
				context.startService(new Intent(context,
						YogaResDownLoadService.class));

			}
		}
	}

}
